package com.bit.ioc;

import com.bit.ioc.component.StudentComponent;
import com.bit.ioc.component.UserComponent;
import com.bit.ioc.config.UserConfig;
import com.bit.ioc.controller.HelloController;
import com.bit.ioc.model.Student;
import com.bit.ioc.rep.UserRepository;
import com.bit.ioc.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(DemoApplication.class, args);
//		//context.getBean(HelloController.class).var()
//		//适合该类型只有一个对象
//		HelloController bean = context.getBean(HelloController.class);
//		bean.print();
//
//		HelloController bean2  = (HelloController) context.getBean("hello");
//		bean2.print();
////
//		HelloController bean3 = context.getBean("helloController", HelloController.class);
//		bean3.print();
//
//		System.out.println(bean);
//		System.out.println(bean2);
//		System.out.println(bean3);

//		UserService bean = context.getBean(UserService.class);
//		bean.print();

//		UserComponent bean = context.getBean(UserComponent.class);
//		bean.print();

//		UserConfig bean = context.getBean(UserConfig.class);
//		bean.print();

//		//@Bean
//		Student bean = (Student) context.getBean("se");
//		System.out.println(bean);
//
//		Student bean1 = (Student) context.getBean("s4");
//		System.out.println(bean);


		//DI依赖测试
		/*HelloController bean = context.getBean(HelloController.class);
		bean.print();*/

//		UserService bean = context.getBean(UserService.class);
//		bean.print();


	}

}
